package com.project.servlet.admin;/*
 *当前的项目名：project
 *当前编辑文件名：CountryListServlet
 *当前用户的登录名：17673122251
 *当前系统日期：2022/5/5
 *当前系统时间：21:13
 */


import com.alibaba.fastjson.JSON;
import com.project.dao.CountryInfoDAO;
import com.project.dao.impl.CountryInfoDAOImpl;
import com.project.entity.CountryInfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/admin/country-list.let")
public class CountryListServlet extends HttpServlet {
    private CountryInfoDAO dao = new CountryInfoDAOImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.reset();
        response.setContentType("application/json;charset=UTF-8");
        try{
            List<CountryInfo> list = dao.select(0,999);
            response.getWriter().print(JSON.toJSONString(list));
        }catch (Exception ex){
            throw new ServletException(ex.getMessage(), ex);
        }
        response.flushBuffer();
    }
}
